home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Developer University / DU Projects / DataSave / Sources / Commands.cpp < prev    next >
Encoding:
Text File  |  1996-08-22  |  1.9 KB  |  81 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 2 $
  2. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //===============================================================
  5. #ifndef COMMANDS_H
  6. #include "Commands.h"        // CPizzaCommand
  7. #endif
  8.  
  9. #ifndef PIZZA_H
  10. #include "Pizza.h"            //  CPizza
  11. #endif
  12.  
  13. #ifndef CONTENT_H
  14. #include "Content.h"        // CDataSaveContent
  15. #endif
  16.  
  17. #ifndef DEFINES_K
  18. #include "Defines.k"        // command numbers
  19. #endif
  20.  
  21. //===============================================================
  22. #ifdef FW_BUILD_MAC
  23. #pragma segment DataCmd
  24. #endif
  25.  
  26. FW_DEFINE_AUTO(CPizzaCommand)
  27.  
  28. //===============================================================
  29. CPizzaCommand::CPizzaCommand(Environment* ev, 
  30.                              ODCommandID id, 
  31.                              FW_CFrame* frame, 
  32.                              CDataSaveContent* content,
  33.                              FW_CPoint position)
  34.   : FW_CCommand(ev, id, frame, FW_kCanUndo),
  35.       fContent(content),
  36.     fPizza(NULL)
  37. {
  38.     this->SetMenuStringsFromResource(ev, kUndoStringsID, 
  39.                             kUndoMakePizzaMsg, kRedoMakePizzaMsg);
  40.     FW_CPoint halfSize( FW_IntToFixed(15), FW_IntToFixed(15) );
  41.     FW_CRect bounds(position - halfSize, position + halfSize);
  42.     fPizza = new CPizza(bounds);
  43.  
  44.     FW_END_CONSTRUCTOR    
  45. }
  46.  
  47. //---------------------------------------------------------------
  48. CPizzaCommand::~CPizzaCommand()
  49. {
  50.     FW_START_DESTRUCTOR    
  51. }
  52.  
  53. //---------------------------------------------------------------
  54. void 
  55. CPizzaCommand::DoIt(Environment* ev)
  56. {
  57.     fContent->MyAddPizza(ev, fPizza);            // add a pizza 
  58. }
  59.  
  60. //---------------------------------------------------------------
  61. void 
  62. CPizzaCommand::UndoIt(Environment* ev)
  63. {
  64.     fContent->MyRemoveLastPizza(ev, fPizza);    // remove a pizza
  65. }
  66.  
  67. //---------------------------------------------------------------
  68. void 
  69. CPizzaCommand::RedoIt(Environment* ev)
  70. {
  71.     this->DoIt(ev);
  72. }
  73.  
  74. //---------------------------------------------------------------
  75. void 
  76. CPizzaCommand::FreeRedoState(Environment* ev)
  77. {
  78.     FW_UNUSED(ev);
  79.     delete fPizza;
  80. }
  81.